

<form class="layui-form" lay-filter="layuiadmin-form-smstm" id="layuiadmin-form-smstm" style="padding: 20px 30px 0 0;">
  <div class="layui-form-item">
    <label class="layui-form-label">供应商</label>
    <div class="layui-input-block">
      <script type="text/html" template lay-done="layui.data.sendParams(d.params)">
        <select name="provider_id" lay-verify="required" id="provider_id">
          <option value=""></option>
        </select>
      </script>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">模板编号</label>
    <div class="layui-input-block">
      <script type="text/html" template>
        <input type="text" name="provider_template_code"  value="{{ d.params.provider_template_code || '' }}"  lay-verify="required"  placeholder="供应商模板编号" autocomplete="off" class="layui-input layui-bg-gray">
      </script>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label"></label>
    <div class="layui-input-inline">
      <input type="button" lay-submit lay-filter="LAY-app-smstm-submit" value="立即提交" class="layui-btn">
    </div>
  </div>
</form>

<script>
    layui.data.sendParams = function(params){
        layui.use(['index', 'form'], function(){
            var $ = layui.$
                ,form = layui.form;
            //供应商下拉框
            $.ajax({
                url:layui.setter.HOST+'providers' //模拟接口
                ,type:"GET"
                ,dataType:"json"
                ,async:true
                ,success:function (res) {
                    if(res.code == 0){
                        for(var i=0;i<res.data.length;i++){
                            if(res.data[i].status == '正常'){
                                $('#provider_id').append("<option value='"+res.data[i].id+"'>"+res.data[i].name+"</option>");
                            }
                            form.render('select');
                            form.val("layuiadmin-form-smstm", {
                                "provider_id": params.provider_id
                            })
                        }
                    }
                }
            });
        })
    };
</script>